export const getTopic = () => {
    return (dispatch) => {
        fetch("https://cnodejs.org/api/v1/topics")
            .then((res) => res.json())
            .then((res) => {
                dispatch({ type: "get_topics_success", payload: res.data });
            });
    };
};
export const loginAction = (user) => {
    return (dispatch) => {
        fetch("http://39.96.84.223:4567/verify/adminlogin", {
            method: "post",
            body: JSON.stringify(user),
        })
            .then((res) => res.json())
            .then((res) => {
                console.log(res);
                dispatch({ type: "loginSuccess", payload: res });
                localStorage.setItem("userinfo", JSON.stringify(res));
            })
            .catch((err) => {
                // console.log(err);
                alert("用户名或者密码不对");
            });
    };
};
